package com.chezhujie.www.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chezhujie.www.domain.DeviceNumber;
import com.chezhujie.www.persistence.DeviceNumberMapper;
import com.xy.core.exception.ClassCheckException;
import com.xy.user.base.service.BaseService;


/**
 * 补录设备号
 * Created by 汤伟杰 on 2017/5/23.
 */
@Service
public class DeviceNumberService extends BaseService<DeviceNumber>{
    @Autowired
    private DeviceNumberMapper devicenumberMapper;

    @Autowired
    public void setBaseMapper(DeviceNumberMapper devicenumberMapper) {
        this.baseMapper = devicenumberMapper;
    }


    public void checkEntity(DeviceNumber devicenumber) throws ClassCheckException {
        if(devicenumber.getDeviceNumberId()!=null&&devicenumber.getDeviceNumberId().length()>255){
            throw new ClassCheckException("补录设备号主键不能超过255个字符");
        }
        if(devicenumber.getOrderCode()!=null&&devicenumber.getOrderCode().length()>255){
            throw new ClassCheckException("补录设备号订单号不能超过255个字符");
        }
        if(devicenumber.getEquipmentSerNum()!=null&&devicenumber.getEquipmentSerNum().length()>255){
            throw new ClassCheckException("补录设备号设备号不能超过255个字符");
        }
    }
    public void checkListEntity(List<DeviceNumber> listDeviceNumber) throws ClassCheckException {

        for (DeviceNumber devicenumber : listDeviceNumber) {
            checkEntity(devicenumber);
        }

    }
}
